<?php
    // +----------------------------------------------------------------------
    // | 海豚PHP框架 [ DolphinPHP ]
    // +----------------------------------------------------------------------
    // | 版权所有 2016~2017 河源市卓锐科技有限公司 [ http://www.zrthink.com ]
    // +----------------------------------------------------------------------
    // | 官方网站: http://dolphinphp.com
    // +----------------------------------------------------------------------
    // | 开源协议 ( http://www.apache.org/licenses/LICENSE-2.0 )
    // +----------------------------------------------------------------------

    namespace app\member\model;


    use think\Db;
    use think\Model;

    class MemberOperationGroupModel extends Model
    {

        // 设置当前模型对应的完整数据表名称
        protected $name = 'member_operation_group';

        // 自动写入时间戳
        protected $autoWriteTimestamp = true;

        /**
         * 查询用户权限
         *
         * @param int $member_id
         * @param int $status
         * @param int $type
         *
         * @return bool
         */
        static public function member_group($member_id = 0,$status = 0,$type = 0)
        {

            $member_group = self::where(['member_id' => $member_id,'status' => $status,'type' => $type])->find();
            if (!empty($member_group))
            {
                return true;
            }
            else
            {
                return false;
            }

        }

        /**
         * 用户表 钱包  资产表
         *
         * @return $this
         */
        static public function getObjectData()
        {

            return Db::view('member_operation_group m','id as group_id,member_id,phone,status,type')//字段
            ->view('payment_wallet pw','money,point','m.member_id=pw.member_id')//字段
            ->view('payment_conf pf','*','m.member_id=pf.member_id')//字段
            ->view('base_wallet_product pt','product_num as num','m.member_id=pt.member_id and pt.product_id = 1')//字段
            ->view('base_wallet_product lock','product_num as lock_num','m.member_id=lock.member_id and lock.product_id = 2')//字段
            ->view('base_wallet_product reward','product_num  as reward_num','m.member_id=reward.member_id and reward.product_id =3');//字段
        }

    }